package org.ymjava.medical.db.AllPackage.biz;

import com.ace.cache.annotation.Cache;
import org.springframework.stereotype.Service;

import org.ymjava.medical.db.AbstractBaseBiz.BaseBiz;
import org.ymjava.medical.db.AllPackage.entity.NurseQuestion;
import org.ymjava.medical.db.AllPackage.mapper.NurseQuestionMapper;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;


/**
 * 
 *
 * @author zhy
 * @email ${email}
 * @date 2020-03-30 13:12:23
 */
@Service
public class NurseQuestionBiz extends BaseBiz<NurseQuestionMapper, NurseQuestion> {


    @Resource
    NurseQuestionMapper mapper;

    @Cache(key = "question-{1}-{2}")
    public List<NurseQuestion> list_question_option(Integer typeId, Integer classId){

        return mapper.queryQuestionAndOption(classId);
    }

    public Integer selectCountByList(List<Integer> list_integer){
        System.out.println(list_integer);
        Example example = new Example(NurseQuestion.class);
        example.createCriteria().andIn("bankId",list_integer).andEqualTo("deleted",0);
        example.orderBy("sort");
        return selectCountByExample(example);
    }

    public List<NurseQuestion> selectQuestionByList(List<Integer> list_integer){
        Example example = new Example(NurseQuestion.class);
        example.createCriteria().andIn("bankId",list_integer).andEqualTo("deleted",0);
        example.orderBy("sort");
        return selectByExample(example);
    }


    public List<NurseQuestion> query_wrong(Integer userId,Integer typeId,Integer classId){
        return mapper.queryWrongQuestion(classId,userId);
    }

    public List<NurseQuestion> query_completed(Integer userId,Integer typeId,Integer classId){
        return mapper.queryCompletedQuetion(classId,userId);
    }

    public List<NurseQuestion> query_no_completed(Integer userId,Integer typeId,Integer classId){
        return  mapper.queryNoCompletedQuetion(classId,userId);
    }

    @Cache(key = "question-type-{1}-{2}")
    public List<NurseQuestion> query_type(Integer classId,Integer question_type){
        return mapper.query_type(classId,question_type);
    }

    public List<NurseQuestion> query_Judge(Integer classId){
        return mapper.query_Judge(classId);
    }

    public List<NurseQuestion> query_Favorite(Integer classId,Integer userId){
        return mapper.query_Favorite(classId,userId);
    }

    @Cache(key = "question-bank-{1}-{2}")
    public List<NurseQuestion> query_bank(Integer classId,Integer bankId){
        return  mapper.query_bank(classId,bankId);
    }


    public List<NurseQuestion> query_mock_question(Integer userId,Integer num, Integer type){
        return mapper.query_mock_question(userId,num,type);
    }
}